<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html">
	<h:head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet"
			href="${request.contextPath}/resources/css/style.css" type="text/css"
			media="screen" />
		<link rel="stylesheet"
			href="${request.contextPath}/resources/css/styleButton.css"
			type="text/css" media="screen" />
		<link rel="shortcut icon"
			href="${request.contextPath}/resources/img/favicon.ico" />
		<title><ui:insert name="title"></ui:insert></title>
	</h:head>
	<h:body>
		<div id="page">
			<div id="menu">
				<ui:insert name="header">
					<center>
						<ui:include src="/template/commonHeader.xhtml" />
					</center>
				</ui:insert>
			</div>
			<div id="line" />

			<div id="content_add">
				<br />
				<h:form id="formAddStudent"
					rendered="#{userLoginBean.user.roles.form_new_student}">
					<p:fieldset styleClass="ptab">
						<p:tab title="User Information">
							<p:growl id="growl" sticky="true" showDetail="true" />
							<p:wizard widgetVar="wiz"
								flowListener="#{userController.onFlowProcess}">
								<p:tab id="user" title="User">
									<p:panel header="User Details" styleClass="panel_back">
										<h:messages errorClass="error" errorStyle="color:red" />
										<h:panelGrid columns="2" columnClasses="label, value"
											id="panelUser">
											<h:panelGroup>
												<h:outputText styleClass="outputText"
													value="Student Number : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<h:panelGroup>
												<p:inputText id="studentN" required="true"
													requiredMessage="Student Number value required"
													label="Student Number"
													value="#{userController.user.user_number}">
													<f:validateLength minimum="4" />
													<p:ajax update="msgPassword" event="keyup" />
												</p:inputText>
												<p:message for="studentN" id="msgPassword" display="icon" />
											</h:panelGroup>

											<h:panelGroup>
												<h:outputText styleClass="outputText" value="Password : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>

											<p:password id="password"
												value="#{userController.user.password}" match="passCnf"
												label="Password" required="true"
												requiredMessage="Password value required"
												promptLabel="Please enter a password" weakLabel="Weak"
												goodLabel="Good" strongLabel="Strong" feedback="true"
												inline="false" />


											<h:panelGroup>
												<h:outputText styleClass="outputText"
													value="Confirm Password : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:password id="passCnf" label="Confirm Password"
												required="true"
												requiredMessage="CPassword must equlas Password" />

											<h:panelGroup>
												<h:outputText styleClass="outputText" value="E-mail : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:inputText required="true" label="E-mail"
												requiredMessage="E-mail value required"
												value="#{userController.user.email_r}" />

											<h:panelGroup>
												<h:outputText styleClass="outputText" value="Gender : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:selectOneMenu value="#{userController.user.sex}"
												style="width:180px;" filterMatchMode="startsWith"
												effect="fold" requiredMessage="Gender cannot be null"
												required="true">
												<f:selectItem itemLabel="Select One" itemValue="" />
												<f:selectItem itemValue="Female" itemLabel="Female" />
												<f:selectItem itemValue="Male" itemLabel="Male" />
											</p:selectOneMenu>

											<h:panelGroup>
												<h:outputText styleClass="outputText" value="Sciency : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:selectOneMenu value="#{userController.user.sciency}"
												requiredMessage="Sciency cannot be null" required="true"
												style="width:180px;" filterMatchMode="startsWith"
												effect="fold" converter="sciencyIdConverter">
												<f:selectItem itemLabel="Select One" itemValue="" />
												<f:selectItems value="#{sciencyContoller.listSciencies}"
													var="sciencyList" itemLabel="#{sciencyList.sciency_name}"
													itemValue="#{sciencyList}" />
											</p:selectOneMenu>

											<h:panelGroup>
												<h:outputText styleClass="outputText"
													value="Roles Sciency : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:selectOneMenu value="#{userController.user.rolesSciency}"
												requiredMessage="Role Sciency cannot be null"
												required="true" style="width:180px;"
												filterMatchMode="startsWith" effect="fold"
												converter="rolesSciencyIdConverter">
												<f:selectItem itemLabel="Select One" itemValue="" />
												<f:selectItems
													value="#{rolesSciencyController.listRolesSciencies}"
													var="rolesSciencyList"
													itemLabel="#{rolesSciencyList.sciency_name}"
													itemValue="#{rolesSciencyList}" />
											</p:selectOneMenu>

											<h:panelGroup>
												<h:outputText styleClass="outputText" value="Roles : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:selectOneMenu value="#{userController.user.roles}"
												requiredMessage="Role cannot be null" required="true"
												style="width:180px;" filterMatchMode="startsWith"
												effect="fold" converter="rolesIdConverter">
												<f:selectItem itemLabel="Select One" itemValue="" />
												<f:selectItems value="#{rolesController.rolesList}"
													var="rolesList" itemLabel="#{rolesList.description}"
													itemValue="#{rolesList}" />
											</p:selectOneMenu>
										</h:panelGrid>

										<p:separator id="seperator" />
										<p:commandLink value="Back to Student Page"
											oncomplete="handleStudentPageRequest(xhr, status, args)"
											style="color:blue" />
									</p:panel>
								</p:tab>

								<p:tab id="student" title="Student">
									<p:panel header="Student Details" styleClass="panel_back">
										<h:messages errorClass="error" errorStyle="color:red" />
										<h:panelGrid columns="2" columnClasses="label, value">
											<h:panelGroup>
												<h:outputText styleClass="outputText" value="Name : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:inputText required="true" label="Student Name"
												value="#{userController.student.name}" />
											<h:panelGroup>
												<h:outputText styleClass="outputText" value="Surname : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:inputText required="true" label="Student Surname"
												value="#{userController.student.surname}" />

											<h:panelGroup>
												<h:outputText styleClass="outputText" value="T.C Number : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:inputMask value="#{userController.student.tc_number}"
												mask="99999999999" />

											<h:panelGroup>
												<h:outputText styleClass="outputText" value="Birth Date :" />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:calendar value="#{userController.student.birth_date}"
												id="popupCal" pattern="dd/MM/yyyy">
												<f:convertDateTime type="date" dateStyle="short"
													pattern="dd/MM/yyyy" />
											</p:calendar>

											<h:panelGroup>
												<h:outputText styleClass="outputText" value="E-mail : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:inputText value="#{userController.student.email}" />

										</h:panelGrid>
									</p:panel>
								</p:tab>

								<p:tab id="Address" title="Address">
									<p:panel header="User Address Information"
										styleClass="panel_back">
										<h:messages errorClass="error" errorStyle="color:red" />
										<h:panelGrid columns="2" columnClasses="label, value">
											<h:panelGroup>
												<h:outputText styleClass="outputText" value="City : " />
												<h:outputText style="color:red; float: right" value=" * " />
											</h:panelGroup>
											<p:inputText value="#{userController.address.city}"
												requiredMessage="City cannot be null" label="City"
												required="false" />

											<h:outputText styleClass="outputText" value="Addres Detail :" />
											<h:panelGroup>
												<p:inputTextarea rows="2" cols="25" counter="counter"
													maxlength="100"
													value="#{userController.address.address_detail}"
													counterTemplate="{0} characters remaining."
													autoResize="false" />
												<h:outputText id="counter" />
											</h:panelGroup>

											<h:outputText styleClass="outputText" value="Zip Code : " />
											<p:inputText value="#{userController.address.zip_postcode}" />

											<h:outputText styleClass="outputText" value="Skip to last: " />
											<h:selectBooleanCheckbox value="#{userController.skip}" />
										</h:panelGrid>
									</p:panel>
								</p:tab>

								<p:tab id="user_confirm" title="User Confirmation">
									<p:panel header="User Confirmation" styleClass="panel_back">
										<p:panelGrid id="user_confirmation" style="margin-top:20px">
											<f:facet name="header">  
								        Student Information
								     </f:facet>
											<p:row>
												<p:column
													style="font-weight: bold; width:200px; background-color:#B8B8B8;">Name</p:column>
												<p:column>
													<h:outputText value="#{userController.student.name}" />
												</p:column>
											</p:row>

											<p:row>
												<p:column
													style="font-weight: bold; width:200px; background-color:#B8B8B8;">Surname Name</p:column>
												<p:column>
													<h:outputText value="#{userController.student.surname}" />
												</p:column>
											</p:row>

											<p:row>
												<p:column
													style="font-weight: bold; width:200px; background-color:#B8B8B8;">User Number</p:column>
												<p:column style="width:200px;">
													<h:outputText value="#{userController.user.user_number}" />
												</p:column>
											</p:row>

											<p:row>
												<p:column
													style="font-weight: bold; width:200px; background-color:#B8B8B8;">T.C Number</p:column>
												<p:column>
													<h:outputText value="#{userController.student.tc_number}" />
												</p:column>
											</p:row>

											<p:row>
												<p:column
													style="font-weight: bold; width:200px; background-color:#B8B8B8;">Birth Date</p:column>
												<p:column>
													<h:outputText value="#{userController.student.birth_date}" />
												</p:column>
											</p:row>

											<p:row>
												<p:column
													style="font-weight: bold; width:200px; background-color:#B8B8B8;">Password</p:column>
												<p:column>
													<h:outputText value="#{userController.user.password}" />
												</p:column>
											</p:row>
											<p:row>
												<p:column
													style="font-weight: bold; width:200px; background-color:#B8B8B8;">Gender</p:column>
												<p:column>
													<h:outputText value="#{userController.user.sex}" />
												</p:column>
											</p:row>
											<p:row>
												<p:column
													style="font-weight: bold; width:200px; background-color:#B8B8B8;">City</p:column>
												<p:column>
													<h:outputText value="#{userController.address.city}" />
												</p:column>
											</p:row>

										</p:panelGrid>
										<p:commandButton value="Save"
											action="#{userController.saveStudent()}"
											styleClass="addButton" update=":formAddStudent, growl" />
										<p:commandButton value="Add New Student"
											actionListener="#{studentController.preparedAdding()}"
											action="newstudent"
											oncomplete="handleStudentAddRequest(xhr, status, args)"
											styleClass="addButton"
											update=":formAddStudent:panelUser ,growl" />
										<p:commandLink value="Back to Student Page"
											oncomplete="handleStudentPageRequest(xhr, status, args)"
											style="color:blue" />
									</p:panel>
								</p:tab>

							</p:wizard>
						</p:tab>
					</p:fieldset>
					<br />
				</h:form>
			</div>

			<div id="line" />
			<br />
			<div id="footer">
				<ui:insert name="footer">
					<ui:include src="/template/commonDock.xhtml" />
				</ui:insert>
			</div>
		</div>

		<script type="text/javascript">
		 	function handleStudentAddRequest(xhr, status, args) {
		       	window.location = "${request.contextPath}/flows/actions/newstudent.jsf?execution=n0s72";
		 	}
		 	function handleStudentPageRequest(xhr, status, args) {
		       	window.location = "${request.contextPath}/flows/actions/allstudent.jsf?execution=n0s72";
		 	}
 		</script>

	</h:body>
</f:view>
</html>
